<?php
/**
 * Created by PhpStorm.
 * User: Vito
 * Date: 2022/3/14
 * Time: 14:22
 */

use app\http\middleware\UserAuthTokenMiddleware;
use think\facade\Route;

define('USER_AUTH_MIDDLEWARE', [UserAuthTokenMiddleware::class, [\app\service\TokenService::USER]]);

Route::group('<api_version>', function () {
    //微信接口
    Route::group('wechat', function () {
        Route::any('message', 'index');
        Route::post('login', 'login');
        Route::get('test', 'test');
        Route::get('getQRcode', 'getQRcode');
        Route::get('sendWorthMessage', 'sendWorthMessage');
        Route::get('sendAuditMessage', 'sendAuditMessage');
        Route::get('timing','timing');
        Route::post('callback', 'callback')->name('wechat_login_callback');

    })->prefix('Wechat/');

    //支付
    Route::group('pay', function () {
        //支付链接
        Route::post('pay', 'pay');
        //同步回调
        Route::any('callback', 'callback');
        //退款
        Route::any('refund', 'refund');

    })->prefix('Pay/');

    //支付异步通知
    Route::post('pay/notify', 'Pay/notify');

    //套餐
    Route::group('product', function () {
        Route::get('', 'index');
    })->prefix('Product/');

    Route::group('adverts', function () {
        Route::get('', 'index');
    })->prefix('Adverts/');

    //订单
    Route::group('order', function () {
        // Route::post('create', 'create')->middleware([USER_AUTH_MIDDLEWARE]);
        Route::post('create', 'create');
        Route::get('detail', 'detail');
        Route::get('status', 'status');
    })->prefix('Order/');

    //用户
    Route::group('user', function () {
        //详情
        Route::get('detail', 'detail');
        Route::get('getDetail', 'getDetail');
        Route::get('sendSms', 'sendSms');
        Route::get('CheckSms', 'CheckSms');
        Route::post('updateUser', 'updateUser');
        Route::get('getSubscribe', 'getSubscribe');
        Route::get('sedUserInfo', 'sedUserInfo');
        Route::get('updateUserInfo', 'updateUserInfo');
    })->prefix('User/');

    //附件
    Route::group('attachment', function () {
        //上传
        Route::post('upload', 'upload');
    })->prefix('Attachment/');

    //房间
    Route::group('room', function () {
        //添加入住申请记录
        Route::post('addCheckRecord', 'addCheckRecord');
        Route::get('getCheckRecord', 'getCheckRecord');
        Route::get('getUserRecord', 'getUserRecord');
        Route::get('getRecordList', 'getRecordList');
        Route::post('addRepairRecord', 'addRepairRecord');
        Route::get('getRepairReocrd', 'getRepairReocrd');
        Route::get('getUserRoom', 'getUserRoom');
        Route::get('getRepairDetail', 'getRepairDetail');
        Route::post('saveRepair', 'saveRepair');
        Route::get('getBuilding', 'getBuilding');
        Route::get('getRoomList', 'getRoomList');
        Route::get('getWaterEle', 'getWaterEle');
        Route::get('get_water_ele_list', 'get_water_ele_list');
        Route::post('addWaterEleRecord', 'addWaterEleRecord');
    })->prefix('Room/');

    //消息
    Route::group('message', function () {
        //添加入住申请记录
        Route::get('getAdverts', 'getAdverts');
        Route::get('getMessage', 'getMessage');
        Route::get('MessageDetail', 'MessageDetail');
        Route::get('getSurrounding', 'getSurrounding');
        Route::get('getSurroundDetail', 'getSurroundDetail');
        Route::get('getNewsDetail', 'getNewsDetail');
    })->prefix('Message/');

    // 保修评价
    Route::resource('repair_rate','RepairRate');
    //巡检记录
    Route::group('polling_record', function () {
        Route::get('getPollingDevice', 'getPollingDevice');
    })->prefix('PollingRecord/');
    Route::resource('polling_record','PollingRecord');
    // Route::group('repair_rate', function () {
    //     //添加报修评价
    //     Route::get('index', 'index');
    //     //添加报修评价
    //     Route::post('save', 'save');
    // })->prefix('RepairRate/');
})->prefix('<api_version>.');
